home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Toolbox / Live Scroll 1.0 / Sources / Initialize.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-13  |  2.3 KB  |  143 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Initialize.c
  3.     
  4.     Contains:    Initialization code for this application
  5.     
  6.     Written by:    Chris White, Developer Technical Support
  7.     
  8.     Copyright:    © 1996 by Apple Computer, Inc., all rights reserved.
  9.     
  10.     Change History (most recent first):
  11.     
  12.             03/29/96            CW        First release
  13.  
  14. */
  15.  
  16.  
  17. #pragma segment Initialize
  18.  
  19.  
  20.  
  21. // System includes
  22.  
  23. #ifndef __QUICKDRAW__
  24.     #include <Quickdraw.h>
  25. #endif
  26.  
  27. #ifndef __FONTS__
  28.     #include <Fonts.h>
  29. #endif
  30.  
  31. #ifndef __TEXTEDIT__
  32.     #include <TextEdit.h>
  33. #endif
  34.  
  35. #ifndef __DIALOGS__
  36.     #include <Dialogs.h>
  37. #endif
  38.  
  39. #ifndef __GESTALT__
  40.     #include <Gestalt.h>
  41. #endif
  42.  
  43. #ifndef __SEGLOAD__
  44.     #include <SegLoad.h>
  45. #endif
  46.  
  47.  
  48.  
  49.  
  50. // Application includes
  51.  
  52. #ifndef __BAREBONES__
  53.     #include "BareBones.h"
  54. #endif
  55.  
  56. #ifndef __PROTOTYPES__
  57.     #include "Prototypes.h"
  58. #endif
  59.  
  60.  
  61.  
  62. // static prototypes
  63. static SInt16 CheckConfiguration ( void );
  64.  
  65.  
  66.  
  67.  
  68. void InitToolbox ( void )
  69. {    
  70.     
  71.     InitGraf ( &qd.thePort );
  72.     InitFonts ( );
  73.     InitWindows ( );
  74.     InitMenus ( );
  75.     TEInit ( );
  76.     InitDialogs ( nil );
  77.     InitCursor ( );
  78.     
  79.     FlushEvents ( everyEvent, 0 );
  80.     
  81.     return;
  82. }
  83.  
  84.  
  85.  
  86. void InitApplication ( void )
  87. {
  88.     SInt16    messageCode;
  89.     
  90.     
  91.     SetMenuBar ( GetNewMBar ( kMenuBarID ) );
  92.     AddResMenu ( GetMHandle ( kAppleMenu ), 'DRVR' );
  93.     DrawMenuBar ( );
  94.     
  95.     messageCode = CheckConfiguration ( );
  96.     if ( messageCode )
  97.     {
  98.         AlertUser ( messageCode, 0, nil );
  99.         ExitToShell ( );
  100.     }
  101.     
  102.     gQuit = false;                          // Initialize flag that controls main event loop
  103.     gInBackground = false;                
  104.     gSleepTime = kSleepTime;
  105.     
  106.     InstallAppleEventHandlers ( );
  107.     CreateWindow ( );
  108.     
  109.     // Create any other RoutineDescriptors we may need
  110.     gScrollControlActionUPP = NewControlActionProc ( ScrollControlActionProc );
  111.     gScrollThumbActionUPP = NewIndicatorActionProc ( ScrollThumbActionProc );
  112.     
  113.     return;
  114. }
  115.  
  116.  
  117.  
  118. static SInt16 CheckConfiguration ( void )
  119. {
  120.     SInt16        messageCode = 0;
  121.     SInt32        theResult;
  122.     OSErr        theErr;
  123.     
  124.     
  125.     // Verify that we can run on the current configuration
  126.     
  127.     // We require AppleEvent Manager and color Quickdraw
  128.     theErr = Gestalt ( gestaltAppleEventsAttr, &theResult );
  129.     if ( !(theErr == noErr && (theResult & (1L << gestaltAppleEventsPresent)) ))
  130.         messageCode = kNeedSystem7;
  131.     
  132.     theErr = Gestalt ( gestaltQuickdrawFeatures, &theResult );
  133.     if ( !(theErr == noErr && (theResult & (1L << gestaltHasColor)) ))
  134.         messageCode = kNeedColorQuickdraw;
  135.     
  136.     
  137.     return messageCode;
  138. }
  139.  
  140.  
  141.  
  142.  
  143.